$OpenBSD: patch-stuncore_stunbuilder_cpp,v 1.2 2016/05/27 22:50:31 sthen Exp $
--- stuncore/stunbuilder.cpp.orig	Sun Jan 17 03:58:21 2016
+++ stuncore/stunbuilder.cpp	Fri May 27 17:53:20 2016
@@ -95,6 +95,7 @@ HRESULT CStunMessageBuilder::AddRandomTransactionId(St
     StunTransactionId transid;
     uint32_t stun_cookie_nbo = htonl(STUN_COOKIE);
 
+#ifndef HAVE_ARC4RANDOM
     uint32_t entropy=0;
 
 
@@ -129,10 +130,11 @@ HRESULT CStunMessageBuilder::AddRandomTransactionId(St
         entropy ^= AtomicIncrement(&g_sequence_number);
     }
 
-#endif
+#endif /* _WIN32 */
 
 
     srand(entropy);
+#endif /* HAVE_ARC4RANDOM */
 
 
     // the first four bytes of the transaction id is always the magic cookie
@@ -140,7 +142,11 @@ HRESULT CStunMessageBuilder::AddRandomTransactionId(St
     memcpy(transid.id, &stun_cookie_nbo, sizeof(stun_cookie_nbo));
     for (int x = 4; x < (STUN_TRANSACTION_ID_LENGTH-4); x++)
     {
+#ifdef HAVE_ARC4RANDOM
+        transid.id[x] = (uint8_t)(arc4random_uniform(256));
+#else
         transid.id[x] = (uint8_t)(rand() % 256);
+#endif
     }
 
     if (pTransId)
